//
//  NSData+Base64.m
//  NewPro
//
//  Created by RYX on 2018/10/24.
//  Copyright © 2018年 何荧红. All rights reserved.
//

@interface NSString (Base64)

- (NSString *) stringPaddedForBase64;

@end

@implementation NSString (Base64)

- (NSString *) stringPaddedForBase64 {
    
    NSUInteger paddedLength = self.length + (self.length % 3);
    NSString *string = [self stringByPaddingToLength:paddedLength withString:@"=" startingAtIndex:0];
    return string;
}

@end

@implementation NSData (Base64)

- (instancetype) initWithBase64EncodedString:(NSString *)base64String {
    
    return [self initWithBase64Encoding:[base64String stringPaddedForBase64]];
    
    
}

- (NSString *) base64EncodedString {
    
    return [self base64Encoding];
    
    
}

@end






